<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<title>CKEditor 5 – document editor build – development sample</title>
	<style>
		body {
			max-width: 1420px;
			margin: 20px auto;
		}
	</style>
	<link rel="stylesheet" href="./ckeditor410/skins/moono/editor.css">
</head>
<body>
<textarea id="ckConfig"></textarea>
<script type="text/javascript" src="./ckeditor410/ckeditor.js"></script>
<script type="text/javascript" src="./ckeditor410/config.js"></script>
<script type="text/javascript">
	CKEDITOR.replace("ckConfig",{
		height : 400,
		startupFocus : true,
		toolbar : "Basic",
	});

	CKEDITOR.instances["ckConfig"].on('instanceReady', function(e) {
		this.document.on("paste", function(e) {
			var items = e.data.$.clipboardData.items;
			console.log(e.data,"--------------------------");
			console.log(items,"=========================")
			for(var i = 0; i < items.length; ++i) {
				var item = items[i];
				if(item.kind == 'file' && item.type == 'image/png') {
					var imgFile = item.getAsFile();
					if(!imgFile) {
						return true;
					}
					var reader = new FileReader();
					reader.readAsDataURL(imgFile);
					reader.onload = function(e) {
						//显示文件
						CKEDITOR.instances["editor1"].insertHtml('<img src="' + this.result + '" alt="" />');
					}
					return false;
				}
			}
		});
	});
</script>

</body>
</html>
